package demo.um.controller;

import java.util.logging.Logger;

import javax.faces.bean.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;

import demo.um.model.UserInfo;
import demo.um.service.UserService;

@Named
@RequestScoped
public class LoginController {

	@Inject
	private Logger log;

	@Inject
	private UserService userService;

	public String login(String username, String password) {
		log.info("User " + username + " trying to login");
		UserInfo user = userService.getUserByName(username);
		if (password.equals(user.getPassword())) {
			return "loginSuccess";
		} else {
			return "loginFailed";
		}
	}

}
